﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ByteArray测试
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] barr = new byte[4];
            foreach (byte b in barr) Console.Write(b.ToString() + " ");
            Console.WriteLine("**************************************");
            barr = GetByteArray();
            foreach (byte b in barr) Console.Write(b.ToString() + " \n");
            double[] dMil = new double[100];
            for(int i = 0; i < dMil.Length; i++)
            {
                long val = 0;
                DateTime dt1 = DateTime.Now;
                for (long l = 1; l < 0xFFFFFFF; l++)
                    val += l;
                DateTime dt2 = DateTime.Now;
                TimeSpan ts = dt2 - dt1;
                dMil[i] = ts.TotalMilliseconds;
                Console.Write("val = " + val.ToString("X") + "；ts.TotalMilliseconds = " + ts.TotalMilliseconds + " ms\n");
            }
            Array.Sort(dMil);
            Console.Write("val_Min = " + dMil.Min() + " ms\n");
            Console.Write("val_Max = " + dMil.Max() + " ms\n");
            Console.Write("val_Average = " + dMil.Average() + " ms\n");

            Console.ReadKey();
        }

        static byte[] GetByteArray()
        {
            byte[] barr = new byte[6];

            for (int i = 0; i < barr.Length; i++) barr[i] = (byte)i;

            return barr;
        }
    }
}
